<template>
	<view class="beijingse">
		<view class="zzdbbox">
			<view class="strongtext xiaobai fonweight">可提现</view>
			<view class="sishi xiaobai margin_top2 fonweight">￥
				<text class="xiaobai fonweight" style="font-size: 70rpx;">{{userInfo.money}}</text>
			</view>
		</view>
		<view class="mainpadding" style="position: relative; top: -110rpx;">
			<view class="ffffff radius mainpadding">
				<view class="ershiba xiaohei">提现金额（元）</view>
				<view class="flexbetween margin_top2">
					<view class="sishi xiaohei margin_top2 flexleft fonweight">￥
						<input type="number" class="xiaohei fonweight" style="font-size: 64rpx;" v-model="money" name="" id="">
					</view>
					<view class="ershiba xiaolan" style="min-width: 120rpx ;"@click="money = userInfo.money">全部提现</view>
				</view>
			</view>
			<view class="mainpadding radius flexbetween ffffff margin_top" @click="jumpurl('/pages/mine/yinhangk?type=1')">
				<view class="ershiba zhonghei">提现至</view>
				<view class="flexright">
					<view class="margin_right2 xiaohei ershiba">{{user_bank_name}}</view>
					<u-icon name="arrow-right" color="#999" size="18"></u-icon>
				</view>
			</view>
			<view class="bigbtn " style="margin-top: 180rpx;" @click="submit">提现</view>
			<view class="xiaolan textcenter margin_top sanshier" @click="jumpurl('/pages/mine/tixianjl')">提现记录</view>
		</view>
	</view>
</template>
<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				userInfo: {},
				money: "", 
				type:1,//1积分提现，2保证金提现
				user_bank_id:"",
				user_bank_name:"",
			}
		},
		onLoad(options) {
			uni.$on("checkyhkfn",data=>{
				this.user_bank_id = data.id
				this.user_bank_name = data.bank.name
			})
			this.type = options.type
			this.userinfomsg()
		},
		onUnload() {
			uni.$off("checkyhkfn")
		},
		methods: {
			userinfomsg() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			submit(){
				if(this.money==""){
					httpRequest.toast("请输入提现金额")
					return false
				}
				if(Number(this.money)>Number(this.userInfo.money)){
					httpRequest.toast("提现金额不可大于可提现金额")
					return false
				}
				
				if(this.user_bank_id==""){
					httpRequest.toast("请选择提现方式")
					return false
				}
				if(this.userInfo.smrz == null){
					httpRequest.toast("未实名认证，无法提现")
					setTimeout(()=>{
						uni.navigateTo({
							url:"/pages/mine/shimingrz"
						})
					},1000)
					return false
				}
				if(this.userInfo.smrz.status == 1){
					httpRequest.toast("实名认证审核中，暂时无法提现")
					return false
				}
				if(this.userInfo.smrz.status == 3){
					httpRequest.toast("实名认证已拒绝审核，请重新提交")
					setTimeout(()=>{
						uni.navigateTo({
							url:"/pages/mine/shimingrz"
						})
					},1000)
					return false
				}
				let data = {
					price:this.money,
					user_bank_id:this.user_bank_id
				}
				let url = "/api/user/addWithdrawal"
				httpRequest.request(url, 'GET', data).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==-1){
						
					}
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zzdbbox {
		background-size: 100% 100%;
		padding: 16rpx 30rpx 100rpx;
		// background-image: url('https://kuaixun.yuntaiqikeji.com/uploads/20240115/72aba476733bb7cd89b5910c897ea17b.png');
		background-color: #3B50FF;
	}
</style>